import React from 'react'
import {Button} from '../../antd'
import Http from "../utils/http"

class AuthButton extends React.Component {

    state = {
        value: false,
    };

    componentDidMount() {
        Http.post({
            url: `${API_URL}auth-hub/auth/checkauth`,
            params: {
                app:'118',
                auth: this.props.auth
            }
        })
            .then(rs => {
                if(rs.code != 0){
                    return;
                }
                this.setState({
                    value: rs.data,
                })
            })
            .catch((error) => {

            });
    }

    render() {
        if(this.state.value== 'true' || this.state.value== true){
            return (
                //<div>
                    <Button type={this.props.type} onClick={this.props.onClick} style={this.props.style}>{this.props.text}</Button>
                // </div>
            );
        }else{
            return '';
        }

    }
}

export default AuthButton;